package com.dong.redBlackTree.entity;

import lombok.Data;

/**
 * 红黑树的节点
 */
@Data
public class RBNode<T extends Comparable<T>> {
    private T key;// 键值
    private RBNode<T> left;// 左子节点
    private RBNode<T> right;// 右子节点
    private RBNode<T> parent;// 父节点
    private boolean color = NodeColor.BLACK;// 颜色

    public RBNode(T key, boolean color, RBNode<T> parent, RBNode<T> left, RBNode<T> right) {
        this.key = key;
        this.color = color;
        this.parent = parent;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return "" + key + (this.color == NodeColor.RED ? "R" : "B");
    }
}
